package dd.lo.classifier;

//import org.datavec.image.loader.NativeImageLoader;
//import org.nd4j.linalg.api.ndarray.INDArray;
//import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
//import org.nd4j.linalg.dataset.api.preprocessor.ImagePreProcessingScaler;
//import org.nd4j.linalg.factory.Nd4j;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ImageClassifier {

    private static final Map<String, Integer> LABELS = new HashMap<>(9);
    static {
        LABELS.put("bright_field", 0);
        LABELS.put("chart", 1);
        LABELS.put("chip", 2);
        LABELS.put("fluorescent", 3);
        LABELS.put("photo", 4);
        LABELS.put("scater", 5);
        LABELS.put("text", 6);
        LABELS.put("tissue", 7);
        LABELS.put("western", 8);
    }
    private static final String RESOURCES_FOLDER_PATH = "/Users/kwok/Downloads";
    private static final int HEIGHT = 28;
    private static final int WIDTH = 28;
    private static final int N_SAMPLES_TRAINING = 60000;
    private static final int N_SAMPLES_TESTING = 10000;
    private static final int N_OUTCOMES = 9;

//    private static DataSetIterator getDataSetIterator(String folderPath, int nSamples) throws IOException {
//        File folder = new File(folderPath);
//        File[] figureFolders = folder.listFiles();
//        NativeImageLoader nativeImageLoader = new NativeImageLoader(HEIGHT, WIDTH);
//        ImagePreProcessingScaler scalar = new ImagePreProcessingScaler(0,1);
//        INDArray input = Nd4j.create(new int[]{nSamples, HEIGHT * WIDTH});
//        INDArray output = Nd4j.create(new int[]{nSamples, N_OUTCOMES});
//        int n = 0;
//        for (File figureFolder: figureFolders) {
//            int labelFigure = LABELS.get(figureFolder.getName());
//            File[] imageFiles = figureFolder.listFiles();
//            for (File imgFile : imageFiles) {
//                INDArray img = nativeImageLoader.asRowVector(imgFile);
//                scalar.transform(img);
//                input.putRow(n, img);
//                output.put(n, labelFigure, 1.0);
//                n++;
//            }
//        }
//        return null;
//    }

    public static void main(String[] args) {

    }
}
